//
// Created by hjie on 23-8-12.
//

#pragma once

#include <cstring>
#include <string>
#include <cstdlib>
#include <vector>
#include <unistd.h>
#include <cstdint>
#include <cstdio>

extern "C"
{
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libavutil/avutil.h>
#include <libavutil/timestamp.h>
#include <libavutil/threadmessage.h>
#include <libavcodec/packet.h>
#include <libavfilter/avfilter.h>
#include <libavutil/mem.h>
#include <libavutil/opt.h>
#include <libavfilter/buffersrc.h>
#include <libavfilter/buffersink.h>
#include <libavutil/avutil.h>
#include <libavutil/pixdesc.h>
#include <libavutil/pixfmt.h>
#include <libavutil/rational.h>


};

class DumpData
{
public:
    DumpData();
    virtual bool InitDump();
    virtual void WriteData(const std::string & data);
    virtual void WriteData(const uint8_t * data, int length);
};

class FileDumpData : public DumpData
{
public:
    FileDumpData();
    virtual ~FileDumpData();
    virtual bool InitDump() override;
    virtual void WriteData(const std::string & data) override;
    virtual void WriteData(const uint8_t * data, int length) override;
private:
    int m_file_desc;
    bool m_init_status;
};


void PrintPacketInfo(AVFormatContext * avformat, AVPacket * packet);
void PrintFrameInfo(AVCodecContext   * codec, AVFrame * frame);





